using SQLServices.Log;

namespace SQLLog4net.Log
{
	/// <summary>
	/// Summary description for PathItem.
	/// </summary>
	public class PathItem : IPathItem
	{

		#region Private Instances

		private string _name;
		private IPathItem _prevNode;
		private IPathItem _nextNode;

		#endregion
		#region Constructor

		public PathItem(string name, IPathItem prevNode)
		{
			_name = name;
			PrevNode = prevNode;
		}

		#endregion
		#region Public Methods

		public string FullPath()
		{
			if (PrevNode == null)
				return _name;
			else
				return _prevNode.FullPath() + "\\" + _name;
		}

		public IPathItem FirstNode()
		{
			if(_prevNode == null) 
				return this;
			else
				return _prevNode.FirstNode();
		}

		#endregion
		#region Properties

		public string Name
		{
			get{ return _name; }
		}

		public IPathItem PrevNode
		{
			get { return _prevNode; }
			set
			{
				_prevNode = value;
				if ( value != null && value.NextNode != this)
					{ value.NextNode = this; }
			}
		}

		public IPathItem NextNode
		{
			get { return _nextNode; }
			set
			{
				_nextNode = value;
				if ( value != null && value.PrevNode != this )
					{ value.PrevNode = this; }
			}
		}


		#endregion

	}
}
